<!DOCTYPE html>
<html ng-app="App">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>{$Think.lang.backoffice_title}</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <!-- UIKIT -->
    <load href="__PUBLIC__/{:UIKIT}/css/uikit.almost-flat.min.css" />
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <load href="__PUBLIC__/Common/js/jquery-1.11.2.min.js" />
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <load href="__PUBLIC__/{:UIKIT}/js/uikit.min.js" />
    <load href="__PUBLIC__/Common/dist/jquery.validate.min.js" />
    <load href="__PUBLIC__/Common/dist/define_methods.js" />
    <load href="__PUBLIC__/{:ANGULARJS}/angular.min.js" />
    <load href="__PUBLIC__/App/CommonDirective.js" />
    <style>
    .uk-table-hover {
        min-width: 1280px;
    }
    
    .tm-footer {
        padding: 50px 0;
        background: #252525;
    }
    
    .tm-footer .uk-subnav-line > li:before {
        border-color: #ddd;
    }
    
    .tm-footer,
    .tm-footer a {
        color: #ddd !important;
    }
    
    .tm-footer a:hover {
        color: #fff !important;
    }
    </style>
    <script style="javascript">
    $(function() {
        //验证FORM

        $("form").each(function() {
            $(this).validate();
        })

    })

    function confirmDelete(url, notice) {
        if (notice === undefined) notice = "Are you sure to remove the item?";
        UIkit.modal.confirm(notice, function() {
            location.href = url;
        });
    }

    App.controller("cartCtrl", ["$scope", function($scope) {
        $scope.cart_items = "{$shopcart.cart_items}";
        $scope.addr_country = "{$addr_country}";
        $scope.addr_city = "{$addr_city}";
        $scope.addToCart = function(pid, num) {
            $.getJSON("__MODULE__/Product/update/pid/" + pid + "/quantity/" + num, function(data) {
                if (data.status) {
                    $scope.cart_items = data.data.cart_items;
                    $scope.$apply();
                    var modal = UIkit.modal("#cart_modal");

                    if (modal.isActive()) {
                        modal.hide();
                    } else {
                        modal.show();
                    }
                } else {
                    //console.log(data);
                    UIkit.modal.alert(data.info);
                }
            });
        }

        $scope.showModal = function(type) {
            if (type == 1) {
                $scope.address_title = "Add new billing address";
                $scope.address_type = 1;
            } else {
                $scope.address_title = "Add new shipping address";
                $scope.address_type = 0;
            }
            var modal = UIkit.modal("#address");

            if (modal.isActive()) {
                modal.hide();
            } else {
                modal.show();
            }
        }
        $scope.chooseCountry = function() {
            $.getJSON("__MODULE__/Public/getState/country_name/" + $scope.addr_country, function(data) {
                $scope.state_list = data;
                $scope.$apply();
            })
        }

        $scope.confirm_order = function() {
            $("#confirm_order").submit();
        }

    }])
    </script>
</head>

<body ng-controller="cartCtrl">
    <div class="uk-container uk-container-center">
        <div class="uk-clearfix">
            <div class="uk-float-right">
                <ul class="uk-subnav uk-subnav-line">
                    <empty name="Think.session.cid">
                        <li><a href="__MODULE__/Public/login">Login</a></li>
                        <li><a href="__MODULE__/Public/login">Register</a></li>
                        <else/>
                        <li>Welcome , <a href="__MODULE__/Customer/index">{$Think.session.id|getObjectInfo='customer','cs_email'}</a></li>
                        <li><a href="__MODULE__/Public/logout">Logout</a></li>
                    </empty>
                    <li><a href="__MODULE__/Product/shopcart">Shopping Cart</a></li>
                    <li><a href="__MODULE__/Orders/checkout">Checkout</a></li>
                </ul>
                <div class="uk-float-right uk-alert uk-icon-cart-arrow-down">&nbsp;&nbsp;<a href="__MODULE__/Product/shopcart">Shopping Cart</a>: now in your cart
                    <b class='uk-text-danger'>{{cart_items}}</b> items
                </div>
            </div>
            <div class="uk-float-left">
                <figure class="uk-thumbnail uk-margin-bottom">
                    <img src="__PUBLIC__/Common/img/logo_mini.png" />
                </figure>
            </div>
        </div>
        <nav class="uk-navbar uk-margin-bottom">
            <ul class="uk-navbar-nav uk-hidden-small">
                <li>
                    <a href="__APP__">Home Pages</a>
                </li>
                <li>
                    <a href="__MODULE__/Product/index">All Products</a>
                </li>
                <li>
                    <a href="__MODULE__/Product/index/label/specials">Specials</a>
                </li>
                <li>
                    <a href="__MODULE__/Product/index/label/new">New Products</a>
                </li>
                <li>
                    <a href="__MODULE__/Rpage/contact">Contact Us</a>
                </li>
                <li>
                    <a href="__MODULE__/Rpage/contact">FAQ</a>
                </li>
            </ul>
            <a href="#offcanvas" class="uk-navbar-toggle uk-visible-small" data-uk-offcanvas></a>
            <div class="uk-navbar-brand uk-navbar-center uk-visible-small">Brand</div>
        </nav>
    </div>
    <div class="uk-container uk-container-center">
        {__CONTENT__}
    </div>
    <hr class="uk-grid-divider">
    <div class="tm-footer">
        <div class="uk-container uk-container-center uk-text-center">
            <ul class="uk-subnav uk-subnav-line uk-flex-center">
                <li><a href="http://github.com/uikit/uikit">GitHub</a></li>
                <li><a href="http://github.com/uikit/uikit/issues">Issues</a></li>
                <li><a href="http://github.com/uikit/uikit/blob/master/CHANGELOG.md">Changelog</a></li>
                <li><a href="https://twitter.com/getuikit">Twitter</a></li>
            </ul>
            <div class="uk-panel">
                <p>Made by <a href="http://www.yootheme.com">YOOtheme</a> with love and caffeine.
                    <br>Licensed under <a href="http://opensource.org/licenses/MIT">MIT license</a>.</p>
                <a href="../index.html"><img src="images/logo_uikit.svg" title="UIkit" alt="UIkit" height="30" width="90"></a>
            </div>
        </div>
    </div>
    <div class="uk-modal" id="cart_modal">
        <div class="uk-modal-dialog">
            <div class="uk-alert uk-alert-success">Add the product to the cart successfully!</div>
            <div class="uk-modal-footer">
                <a class="uk-button uk-modal-close" href="#">Continue to shop</a>
                <a class="uk-button uk-button-primary" href="__MODULE__/Orders/checkout">Check Out</a>
            </div>
        </div>
    </div>
</body>

</html>
